﻿using System;
using System.Xml;
using cz.uhul.DSMLv2;
using cz.uhul.DSMLv2.client;


namespace testDSML
{


  public class testDSMLClient
  {


    public static void go()
    {
      LdConnection conn = LdConnection.CreateConnection(new Uri("http://localhost:4519/LdConnection.svc"));
      //LdConnection conn = LdConnection.CreateConnection(new Uri("https://eagri.cz/ssl/basic-app/uhul/wtest/LDS/LdConnection.svc"));

      Console.WriteLine(conn.Endpoint.Address);

      //conn.ClientCredentials.UserName.UserName = "sidaa";
      //conn.ClientCredentials.UserName.Password = "Kacenka.24";

      string postMsg = @"<?xml version='1.0' encoding='UTF-8'?>
    <batchRequest
      xmlns:xsd='http://www.w3.org/2001/XMLSchema'
      xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
      xmlns='urn:oasis:names:tc:DSML:2:0:core'
      requestID='Batch of search requests'
      responseOrder='Unordered'
    >
      <searchRequest
        dn='cn=config'
        requestID='search on Root DSE'
        scope='wholeSubtree'
        derefAliases='neverDerefAliases'
        typesOnly='false'
      >
        <filter>
          <present name='objectClass'/>
        </filter>
      </searchRequest>
    </batchRequest>
    ";

      LdRequestDocument rd = LdRequestDocument.Parse(postMsg);

      LdResponseDocument respd = conn.SendRequest(rd);

      XmlDocument xd = respd.ToXml();
    }

  }

}
